﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace FAQ_UI
{
	public class Recycler
	{
		private Queue<ViewHolder> mRemovedViewQueue = new Queue<ViewHolder>();

		public ViewHolder get()
		{
			return mRemovedViewQueue.Count == 0 ? null : mRemovedViewQueue.Dequeue();
		}

		public void put(Panel parent, UIElement child)
		{
			parent.Children.Remove(child);
			ViewHolder viewHolder = (ViewHolder)child.GetValue(ViewHolder.k);
			mRemovedViewQueue.Enqueue(viewHolder);
		}
	}
}